Certified HLints with Isabelle/HOLCF-Prelude
نویسندگان
چکیده
We present the HOLCF-Prelude, a formalization of a large part of Haskell’s standard prelude in Isabelle/HOLCF. Applying this formalization to the hints suggested by HLint allows us to certify them formally. In pure functional languages such as Haskell, equational reasoning is a valuable tool for refactoring, to improve both efficiency and aesthetics. For example, an experienced programmer would replace reverse ".txt" `isPrefixOf` reverse filename with the more readable (and more efficient) ".txt" `isSuffixOf` filename. In this paper we call such a replacement a rewrite. We only want to apply rewrites that are valid and thus some natural questions arise: Is the original expression equivalent to the replaced expression? With a language like Haskell, this entails the question: What about when infinite or undefined values are involved? To highlight some of the issues, consider another example. Assuming the definition reverse [] = [] reverse (x:xs) = reverse xs ++ [x] can we safely apply the following rewrite? reverse (reverse xs) = xs (?) Let us try to prove (?) by induction: • Base case (xs = []). Just apply the definition of reverse. • Step case (xs = y:ys). We have: reverse (reverse (y:ys)) = reverse (reverse ys ++ [y]) (by definition of reverse) = reverse [y] ++ reverse (reverse ys) (using an auxiliary lemma) = reverse [y] ++ ys (by induction hypothesis) = y:ys Such fast-and-loose reasoning [2] is oftentimes useful, but may fail for lazy languages: The above rewrite is neither valid for infinite xs, nor when xs contains undefined values on the spine. In addition to the above cases, we should have considered the undefined input ⊥ (pronounced bottom) and made sure that the desired property is admissible for our setting. These extra requirements can be tricky to follow, so automated assistance would be welcome. Such assistance is available using higher-order logic for computable functions (HOLCF, [5]). HOLCF is based on the higher-order logic (HOL) instance of the proof assistant Isabelle [7] that provides functions, recursive definitions, (data) types, type classes, etc.; and constitutes a domain-theoretic framework that allows us to generate types in HOL that match the denotation ∗Supported by the Deutsche Telekom Stiftung. †Supported by the Austrian Science Fund (FWF): J3202. 1See [5] for a formal definition of admissibility.
منابع مشابه
HOLCF: Higher Order Logic of Computable Functions
This paper presents a survey of HOLCF a higher order logic of computable functions The logic HOLCF is based on HOLC a variant of the well known higher order logic HOL which o ers the additional concept of type classes HOLCF extends HOLC with concepts of domain theory such as complete partial orders continuous functions and a xed point operator With the help of type classes the extension can be ...
متن کاملTraces of I/O-Automata in Isabelle/HOLCF
This paper presents a formalization of nite and in nite se quences in domain theory carried out in the theorem prover Isabelle The results are used to model the metatheory of I O automata they are however applicable to any trace based model of parallelism which distinguishes internal and external actions We make use of the logic HOLCF an extension of HOL with domain theory and show how to move ...
متن کاملTraces of I / O - Automata in Isabelle / HOLCFOlaf
This paper presents a formalization of nite and innnite sequences in domain theory carried out in the theorem prover Isabelle. The results are used to model the metatheory of I/O automata; they are, however, applicable to any trace based model of parallelism which distinguishes internal and external actions. We make use of the logic HOLCF, an extension of HOL with domain theory and show how to ...
متن کاملReasoning with Powerdomains in Isabelle/HOLCF
This paper presents the first fully-mechanized formalization of powerdomains, implemented in the HOLCF logic of the Isabelle theorem prover. The powerdomain library provides an abstract view of powerdomains to the user, hiding the complicated implementation details. The library also provides proof automation, in the form of sets of rewrite rules for solving equalities and inequalities on powerd...
متن کاملAxiomatic Constructor Classes in Isabelle/HOLCF
We have definitionally extended Isabelle/HOLCF to support axiomatic Haskell-style constructor classes. We have subsequently defined the functor and monad classes, together with their laws, and implemented state and resumption monad transformers as generic constructor class instances. This is a step towards our goal of giving modular denotational semantics for concurrent lazy functional programm...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
- CoRR
دوره abs/1306.1340 شماره
صفحات -
تاریخ انتشار 2013